#include "Direction.h"

Direction::Direction()
{
    dirX = 0;
    dirY = 0;
}

Direction::~Direction()
{
}

void Direction::clear()
{
    dirX = 0;
    dirY = 0;
}

void Direction::addUp()
{
    if(dirY < 1)
        dirY += 1;
}

void Direction::addLeft()
{
    if(dirX > -1)
        dirX -= 1;
}

void Direction::addRight()
{
    if(dirX < 1)
        dirX += 1;
}

void Direction::addDown()
{
    if(dirY > -1)
        dirY -= 1;
}

void Direction::add(const Direction & direction)
{
    dirY = dirY + direction.dirY;
    if(dirY < -1) 
        dirY = -1;
    if(dirY > 1) 
        dirY = 1;
    
    dirX = dirX + direction.dirX;
    if(dirX < -1) 
        dirX = -1;
    if(dirX > 1) 
        dirX = 1;
}


Direction & Direction::operator=(Direction & other)
{
    dirX = other.dirX;
    dirY = other.dirY;

    return *this;
}

int Direction::getDirectionX() const
{
    return dirX;
}

int Direction::getDirectionY() const
{
    return dirY; 
}

